<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>string::reserve</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.JSON">
<link rel="up" href="../boost__json__string.html" title="string">
<link rel="prev" href="capacity.html" title="string::capacity">
<link rel="next" href="shrink_to_fit.html" title="string::shrink_to_fit">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="capacity.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost__json__string.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="shrink_to_fit.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="json.ref.boost__json__string.reserve"></a><a class="link" href="reserve.html" title="string::reserve">string::reserve</a>
</h5></div></div></div>
<p>
          <a class="indexterm" name="idm45725630206784"></a>
        </p>
<p>
          Increase the capacity to at least a certain amount.
        </p>
<h6>
<a name="json.ref.boost__json__string.reserve.h0"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.synopsis"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.synopsis">Synopsis</a>
        </h6>
<pre class="programlisting"><span class="keyword">void</span>
<span class="identifier">reserve</span><span class="special">(</span>
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span> <span class="identifier">new_capacity</span><span class="special">);</span>
</pre>
<h6>
<a name="json.ref.boost__json__string.reserve.h1"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.description"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.description">Description</a>
        </h6>
<p>
          This increases the capacity of the array to a value that is greater than
          or equal to <code class="computeroutput"><span class="identifier">new_capacity</span></code>.
          If <code class="computeroutput"><span class="identifier">new_capacity</span> <span class="special">&gt;</span>
          <span class="identifier">capacity</span><span class="special">()</span></code>,
          new memory is allocated. Otherwise, the call has no effect. The number
          of elements and therefore the <a class="link" href="size.html" title="string::size"><code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a>
          of the container is not changed.
        </p>
<h6>
<a name="json.ref.boost__json__string.reserve.h2"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.complexity"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.complexity">Complexity</a>
        </h6>
<p>
          At most, linear in <a class="link" href="size.html" title="string::size"><code class="computeroutput"><span class="identifier">size</span><span class="special">()</span></code></a>.
        </p>
<h6>
<a name="json.ref.boost__json__string.reserve.h3"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.exception_safety"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.exception_safety">Exception
          Safety</a>
        </h6>
<p>
          Strong guarantee. Calls to <code class="computeroutput"><span class="identifier">memory_resource</span><span class="special">::</span><span class="identifier">allocate</span></code>
          may throw.
        </p>
<h6>
<a name="json.ref.boost__json__string.reserve.h4"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.remarks"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.remarks">Remarks</a>
        </h6>
<p>
          If new memory is allocated, all iterators including any past-the-end iterators,
          and all references to the elements are invalidated. Otherwise, no iterators
          or references are invalidated.
        </p>
<h6>
<a name="json.ref.boost__json__string.reserve.h5"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.parameters"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.parameters">Parameters</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Name
                  </p>
                </th>
<th>
                  <p>
                    Description
                  </p>
                </th>
</tr></thead>
<tbody><tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">new_capacity</span></code>
                  </p>
                </td>
<td>
                  <p>
                    The new capacity of the array.
                  </p>
                </td>
</tr></tbody>
</table></div>
<h6>
<a name="json.ref.boost__json__string.reserve.h6"></a>
          <span class="phrase"><a name="json.ref.boost__json__string.reserve.exceptions"></a></span><a class="link" href="reserve.html#json.ref.boost__json__string.reserve.exceptions">Exceptions</a>
        </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                  <p>
                    Type
                  </p>
                </th>
<th>
                  <p>
                    Thrown On
                  </p>
                </th>
</tr></thead>
<tbody><tr>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">length_error</span></code>
                  </p>
                </td>
<td>
                  <p>
                    <code class="computeroutput"><span class="identifier">new_capacity</span> <span class="special">&gt;</span> <span class="identifier">max_size</span><span class="special">()</span></code>
                  </p>
                </td>
</tr></tbody>
</table></div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2019, 2020 Vinnie Falco<br>Copyright © 2020 Krystian Stasiowski<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="capacity.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost__json__string.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="shrink_to_fit.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
